package com.joinval.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.joinval.common.base.entity.BaseEntity;
import com.joinval.common.validator.group.AddGroup;
import com.joinval.common.validator.group.UpdateGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;

/**
 * 系统用户
 *
 * @author Mark sunlightcs@gmail.com
 */
@Data
@TableName("sys_user")
@Accessors(chain = true)
public class SysUserEntity extends BaseEntity {
	private static final long serialVersionUID = 1L;

	/**
	 * 用户ID
	 */
	@TableId
	private Long userId;

	/**
	 * 用户名
	 */
	@NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@Length(max = 200,message = "用户名最长为200字符")
	private String username;

	/**
	 * 真实姓名
	 */
	@NotBlank(message="真实姓名不能为空")
	@Length(max = 200,message = "用户名最长为200字符")
	private String realName;

	/**
	 * 密码
	 */
	@NotBlank(message="密码不能为空", groups = AddGroup.class)
	private String password;

	/**
	 * 盐
	 */
	private String salt;

	/**
	 * 性别(0-男, 1-女)
	 */
	private Integer gender;

	/**
	 * 个人头像
	 */
	private String logo;

	/**
	 * 部门
	 */
	private String dept;

	/**
	 * 签章地址
	 */
	private String stampUrl;

	/**
	 * 照片地址
	 */
	private String photoUrl;

	/**
	 * 存证id
	 */
	private String licSrcId;

	/**
	 * 类型(0:后台用户,1:小程序端用户)
	 */
	private String userType;

	/**
	 * 微信opnId
	 */
	private String openId;

	/**
	 * 身份证号
	 */
	private String idCard;

	/**
	 * 生日
	 */
	@ApiModelProperty(value = "生日",name = "birthday")
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date birthday;


	/**
	 * 联系人
	 */
	private String linkman;

	/**
	 * 联系人电话
	 */
	private String cntPhone;


	/**
	 * 联系人地址
	 */
	private String cntAddress;


	/**
	 * 邮箱
	 */
	//@NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
	//@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
	@Length(max = 100,message = "邮箱最长为100字符")
	private String email;

	/**
	 * 手机号
	 */
	@Length(max = 20,message = "手机号最长为20字符")
	private String mobile;

	/**
	 * 状态  0：禁用   1：正常
	 */
	private Integer status;

	/**
	 * 角色ID列表
	 */
	@TableField(exist=false)
	private List<Long> roleIdList;

	/**
	 * 创建者ID
	 */
	private Long createUserId;

	/**
	 * 商户id
	 */
	private Long enterpriseId;

	/**
	 * 省ids
	 */
	@ApiModelProperty(value = "省id")
	private String provinceId;

	/**
	 * 市ids
	 */
	@ApiModelProperty(value = "市id")
	private String cityId;


	/**
	 * 区县ids
	 */
	@ApiModelProperty(value = "区县id")
	private String countyId;


	/**
	 * 街镇ids
	 */
	@ApiModelProperty(value = "街镇id-多个逗号拼接")
	private String townId;

}
